Nonterminals pass call args exprs lor land cond expr term factor.

Terminals 'boolean' 'integer' 'string' 'name' 
		  '.' '[' ']' '(' ')' ',' ':'
		  '==' '!=' '<' '<=' '>' '>=' '&&' '||' '!'
		  '+' '-' '*' '/'.


Rootsymbol lor.

exprs -> lor :				['$1'].
exprs -> lor ',' exprs : 	['$1'|'$3'].

lor  -> land :  			'$1'.
lor  -> land '||' lor :		lor('$1', '$3').
land -> cond :  			'$1'.
land -> cond '&&' land :	land('$1', '$3').

cond -> expr :	  	   		'$1'.
cond -> expr '==' cond :	equal('$1', '$3').
cond -> expr '!=' cond :	not_equal('$1', '$3').
cond -> expr '<'  cond :	lt('$1', '$3').
cond -> expr '<=' cond :	leq('$1', '$3').
cond -> expr '>'  cond :	gt('$1', '$3').
cond -> expr '>=' cond :	geq('$1', '$3').

expr -> term : 	  	   		'$1'.
expr -> term '+' expr : 	add('$1', '$3').
expr -> term '-' expr : 	sub('$1', '$3').

term -> factor : 	  		'$1'.
term -> factor '*' term : 	mul('$1', '$3').
term -> factor '/' term : 	divide('$1', '$3').

factor -> boolean : 	  	value_of('$1').
factor -> integer : 	  	value_of('$1').
factor -> string :			value_of('$1').
factor -> pass :			value_of('$1').
factor -> call :			'$1'.
factor -> '!' factor :		negate('$2').
factor -> '-' factor :		minus('$2').
factor -> '(' lor ')' : 	('$2').

pass -> name :				get_by_key('$1').
pass -> pass '.' name : 	get_by_key('$1', '$3').
pass -> pass '.' integer : 	get_by_key('$1', '$3').
pass -> pass '[' expr ']' : get_by_index('$1', '$3').

% nameの場合だけ特別扱い
call -> name ':' name args : call('$1', '$3', '$4').
call -> pass ':' pass args : call('$1', '$3', '$4').

args -> '(' ')' : 		   	[].
args -> '(' exprs ')' :		args('$2').


Erlang code.
-import(templel_parse_handler, [lor/2,land/2,
								equal/2,not_equal/2,lt/2,leq/2,gt/2,geq/2,
							   	add/2,sub/2,mul/2,divide/2,negate/1,minus/1,block/1,
								get_by_key/1,get_by_key/2,get_by_index/2,
								call/3,args/1]).

value_of({_,_,Val}) ->
	Val;
value_of(Fun) when is_function(Fun) ->
	fun(VT) -> value_of(Fun(VT)) end.
